/*
 Navicat Premium Dump SQL

 Source Server         : meeting-room
 Source Server Type    : MySQL
 Source Server Version : 90100 (9.1.0)
 Source Host           : localhost:3308
 Source Schema         : meeting_room

 Target Server Type    : MySQL
 Target Server Version : 90100 (9.1.0)
 File Encoding         : 65001

 Date: 25/10/2024 15:23:17
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for booking
-- ----------------------------
DROP TABLE IF EXISTS `booking`;
CREATE TABLE `booking` (
  `id` int NOT NULL AUTO_INCREMENT,
  `startTime` datetime NOT NULL COMMENT '会议开始时间',
  `endTime` datetime NOT NULL COMMENT '会议结束时间',
  `status` varchar(20) NOT NULL DEFAULT '申请中' COMMENT '状态（申请中、审批通过、审批驳回、已解除）',
  `note` varchar(100) NOT NULL DEFAULT '' COMMENT '备注',
  `createTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间',
  `updateTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间',
  `userId` int DEFAULT NULL,
  `roomId` int DEFAULT NULL COMMENT '会议室ID',
  PRIMARY KEY (`id`),
  KEY `FK_336b3f4a235460dc93645fbf222` (`userId`),
  KEY `FK_769a5e375729258fd0bbfc0a456` (`roomId`),
  CONSTRAINT `FK_336b3f4a235460dc93645fbf222` FOREIGN KEY (`userId`) REFERENCES `users` (`id`),
  CONSTRAINT `FK_769a5e375729258fd0bbfc0a456` FOREIGN KEY (`roomId`) REFERENCES `meeting_room` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of booking
-- ----------------------------
BEGIN;
INSERT INTO `booking` (`id`, `startTime`, `endTime`, `status`, `note`, `createTime`, `updateTime`, `userId`, `roomId`) VALUES (3, '2024-10-25 08:00:00', '2024-10-25 12:00:00', '审批通过', '', '2024-10-25 07:15:12.878269', '2024-10-25 07:15:33.000000', 2, 2);
COMMIT;

-- ----------------------------
-- Table structure for meeting_room
-- ----------------------------
DROP TABLE IF EXISTS `meeting_room`;
CREATE TABLE `meeting_room` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '会议室ID',
  `name` varchar(50) NOT NULL COMMENT '会议室名字',
  `capacity` int NOT NULL COMMENT '会议室容量',
  `location` varchar(50) NOT NULL COMMENT '会议室位置',
  `equipment` varchar(50) NOT NULL DEFAULT '' COMMENT '设备',
  `description` varchar(100) NOT NULL DEFAULT '' COMMENT '描述',
  `isBooked` tinyint NOT NULL DEFAULT '0' COMMENT '是否被预订',
  `createTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) COMMENT '创建时间',
  `updateTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of meeting_room
-- ----------------------------
BEGIN;
INSERT INTO `meeting_room` (`id`, `name`, `capacity`, `location`, `equipment`, `description`, `isBooked`, `createTime`, `updateTime`) VALUES (2, '1号会议室', 10, 'A座3层301', '华为投影仪', '研发部会议', 0, '2024-10-25 07:14:38.816993', '2024-10-25 07:14:38.816993');
COMMIT;

-- ----------------------------
-- Table structure for permissions
-- ----------------------------
DROP TABLE IF EXISTS `permissions`;
CREATE TABLE `permissions` (
  `id` int NOT NULL AUTO_INCREMENT,
  `code` varchar(20) NOT NULL COMMENT '权限代码',
  `description` varchar(100) NOT NULL COMMENT '权限描述',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of permissions
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for role_permissions
-- ----------------------------
DROP TABLE IF EXISTS `role_permissions`;
CREATE TABLE `role_permissions` (
  `rolesId` int NOT NULL,
  `permissionsId` int NOT NULL,
  PRIMARY KEY (`rolesId`,`permissionsId`),
  KEY `IDX_0cb93c5877d37e954e2aa59e52` (`rolesId`),
  KEY `IDX_d422dabc78ff74a8dab6583da0` (`permissionsId`),
  CONSTRAINT `FK_0cb93c5877d37e954e2aa59e52c` FOREIGN KEY (`rolesId`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_d422dabc78ff74a8dab6583da02` FOREIGN KEY (`permissionsId`) REFERENCES `permissions` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of role_permissions
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for roles
-- ----------------------------
DROP TABLE IF EXISTS `roles`;
CREATE TABLE `roles` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(20) NOT NULL COMMENT '角色名',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of roles
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user_roles
-- ----------------------------
DROP TABLE IF EXISTS `user_roles`;
CREATE TABLE `user_roles` (
  `usersId` int NOT NULL,
  `rolesId` int NOT NULL,
  PRIMARY KEY (`usersId`,`rolesId`),
  KEY `IDX_99b019339f52c63ae615358738` (`usersId`),
  KEY `IDX_13380e7efec83468d73fc37938` (`rolesId`),
  CONSTRAINT `FK_13380e7efec83468d73fc37938e` FOREIGN KEY (`rolesId`) REFERENCES `roles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_99b019339f52c63ae6153587380` FOREIGN KEY (`usersId`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of user_roles
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for users
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL COMMENT '用户名',
  `password` varchar(50) NOT NULL COMMENT '密码',
  `nick_name` varchar(50) NOT NULL COMMENT '昵称',
  `email` varchar(50) NOT NULL COMMENT '邮箱',
  `headPic` varchar(100) DEFAULT NULL COMMENT '头像',
  `phoneNumber` varchar(20) DEFAULT NULL COMMENT '手机号',
  `isFrozen` tinyint NOT NULL DEFAULT '0' COMMENT '是否冻结',
  `isAdmin` tinyint NOT NULL DEFAULT '0' COMMENT '是否是管理员',
  `loginType` int NOT NULL DEFAULT '0' COMMENT '登录类型, 0 用户名密码登录, 1 Google 登录, 2 Github 登录',
  `createTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `updateTime` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  UNIQUE KEY `IDX_fe0bb3f6520ee0469504521e71` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- ----------------------------
-- Records of users
-- ----------------------------
BEGIN;
INSERT INTO `users` (`id`, `username`, `password`, `nick_name`, `email`, `headPic`, `phoneNumber`, `isFrozen`, `isAdmin`, `loginType`, `createTime`, `updateTime`) VALUES (1, 'admin', '1962fc1d944a50eccabd39304cd2669a', '超级管理员', '415340716@qq.com', 'http://localhost:9000/meeting-room/avatar1.jpg', NULL, 0, 1, 0, '2024-10-25 06:24:18.746528', '2024-10-25 07:07:00.291913');
INSERT INTO `users` (`id`, `username`, `password`, `nick_name`, `email`, `headPic`, `phoneNumber`, `isFrozen`, `isAdmin`, `loginType`, `createTime`, `updateTime`) VALUES (2, 'test1', '1962fc1d944a50eccabd39304cd2669a', '测试1', '415340716@qq.com', 'http://localhost:9000/meeting-room/avatar2.jpg', NULL, 0, 0, 0, '2024-10-25 14:34:33.000000', '2024-10-25 07:21:24.978054');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
